<template>
  <el-table
      :data="useExportTable"
      header-align="center"
      v-loading="loading"
      element-loading-text="请稍等...">
    <el-table-column prop="antiFakeSealId" label="防伪印章ID" align="center" />
    <el-table-column prop="antiFakeUser" label="导出人" align="center" />
    <el-table-column prop="antiFakeTime" label="导出时间" align="center" />
    <el-table-column prop="antiFakeIntroduction" label="导出说明" align="center" />
  </el-table>
  <el-pagination
      :page-sizes="[10, 15, 20, 25]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="totalNum"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      align="center"
  >
  </el-pagination>
</template>

<script setup>
// 导出自用--分页代码
import {ref,getCurrentInstance} from 'vue';
import {getAntiFakeSealListByTemplateIdApi, getAntiFakeSealNumByTemplateIdApi} from '../../../api/sealAntiFake';
import {dateFormat} from '../../../utils/util';
import {ElMessage} from 'element-plus';
import {defineProps} from 'vue';

const {proxy} = getCurrentInstance()
const loading = ref(false)

//获取父组件传参的数据
const props =defineProps({
  sealId: "",
})
let sealId = props.sealId

/**
 * 获取列表
 * @param purpose
 */
const getAntiFakeSealListByTemplateId = (purpose) =>{
  loading.value = true
  getAntiFakeSealListByTemplateIdApi(currentPage.value,pageSize.value,sealId,purpose)
      .then(res=>{
        let data = res.data.result
        for(let i=0;i<data.length;i++){
          data[i].antiFakeTime = dateFormat("YYYY-mm-dd HH:MM:SS",new Date(data[i].antiFakeTime))
        }
        useExportTable.value = data
        loading.value = false
      }).catch(res=>{
    ElMessage.error(res)
  })
}
/**
 * 获取数量
 * @param purpose
 */
const getAntiFakeSealNumByTemplateId = (purpose) => {
  getAntiFakeSealNumByTemplateIdApi(sealId,purpose)
      .then(res=>{
        let data = res.data.result
        totalNum.value = data
      }).catch(res=>{
    ElMessage.error(res)
  })
}

const useExportTable = ref([])

// 签署文件--分页代码
const totalNum = ref(0)
const currentPage=ref(1)
const pageSize=ref(10)

const handleCurrentChange = (currPage) => {
  currentPage.value = currPage
  getAntiFakeSealListByTemplateId(1)
  window.scrollTo(0, 175);
}

const handleSizeChange = (val) => {
  pageSize.value=val
  getAntiFakeSealListByTemplateId(1)
}

/**
 * 获取 导出自用 列表
 */
getAntiFakeSealListByTemplateId(0)
getAntiFakeSealNumByTemplateId(0)
</script>

<style scoped>
.status_icon{
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: red;
  display: inline-block;
  position: relative;
  vertical-align: middle;
  margin-right: 6px;
}
</style>
